package com.jt.tenant.conn;

import com.jt.tenant.app.JTApplication;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * 行程报告-详情
 */
@HttpInlet(Conn.INLET_TRAVEL_REPORT)
public class GetTravelReport extends JTAsyGet<GetTravelReport.Info> {

    public String token = JTApplication.jtPreferences.readToken();

    public String obdid = JTApplication.jtPreferences.readOdbID();

    public String travelid;

    public GetTravelReport(String travelid, AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);

        this.travelid = travelid;

    }

    @Override
    protected Info parser(JSONObject object) {

        JSONObject apiTYF = object.optJSONObject("apiTYF");

        JSONObject head = apiTYF.optJSONObject("head");

        Info info = new Info();

        info.msg = head.optString("msg");

        JSONObject body = apiTYF.optJSONObject("body");

        info.price = body.optString("price");

        JSONObject travel = body.optJSONObject("travel");

        info.endTime = travel.optString("endTime");

        info.startTime = travel.optString("startTime");

        info.fuel = travel.optString("fuel");

        info.mileage = travel.optString("mileage");

        info.maxspeed = travel.optString("maxspeed");

        info.avgspeed = travel.optString("avgspeed");

        info.speedUp = travel.optString("speedUp");

        info.speedDown = travel.optString("speedDown");

        info.startName = travel.optString("startName");

        info.endName = travel.optString("endName");

        info.turn_count = travel.optString("turn_count");

        info.avgengine = travel.optString("avgengine");

        info.highspeedCount = travel.optString("highspeedCount");

        info.driver_flag = travel.optString("driver_flag");

        return info;

    }

    public static class Info {

        public String msg;

        public String endTime, startTime, fuel, price,mileage, maxspeed, avgspeed, speedUp, speedDown, startName, endName, turn_count, avgengine, highspeedCount, driver_flag;
    }
}
